import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from utils import ArgumentParser, LOG, SupportedModels, validate_model
from translator import PDFTranslator, TranslatorConfig

if __name__ == '__main__':
    # 解析命令行参数
    argument_parser = ArgumentParser()
    args = argument_parser.parse_arguments()

    # 初始化配置单例
    config = TranslatorConfig()
    config.initialize(args)
    
    # 初始化支持模型配置单例
    supported_models = SupportedModels()
    supported_models.initialize(args.supported_models)

    # 验证模型是否支持
    validate_model(config.model, supported_models.get(config.model_type))

    # 创建 translator 并进行翻译与保存
    translator = PDFTranslator(config.model_type, config.model)
    translator.translate_pdf(config.input_file_path, config.output_file_format, config.output_file_path)